package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	// code = 1000.. 用户模块的错误
	ERROR_USERNAME_USED  = 1001
	ERROR_PASSWORD_WORNG = 1002
	ERROR_USER_NOT_EXIST = 1003
	ERROR_TOKEN_EXIST    = 1004
	ERROR_TOKEN_RUNTIME  = 1005
	ERROR_TOKEN_WRONG    = 1006
	ERROR_TOKEN_TYPE     = 1007
	ERROR_USER_NOT_RIGHT = 1008

	// code = 2000... 文章模块的错误
	ERROR_ARTICLENAME_USED = 2001
	ERROR_ART_NOT_EXIST    = 2002
	// code = 3000... 分类模块的错误
	ERROR_CATANAME_USED = 3001
)

var codeMsg = map[int]string{
	SUCCESS:                "OK",
	ERROR:                  "FAIL",
	ERROR_USERNAME_USED:    "用户名已存在",
	ERROR_PASSWORD_WORNG:   "密码错误",
	ERROR_USER_NOT_EXIST:   "用户不存在",
	ERROR_USER_NOT_RIGHT:   "无权登录",
	ERROR_TOKEN_EXIST:      "Token鉴权失败",
	ERROR_TOKEN_RUNTIME:    "Token已过期",
	ERROR_TOKEN_WRONG:      "Token不正确",
	ERROR_TOKEN_TYPE:       "Token格式错误",
	ERROR_ARTICLENAME_USED: "文章名称已存在",
	ERROR_ART_NOT_EXIST:    "文章不存在",
	ERROR_CATANAME_USED:    "该分类已经存在",
}

// 输出错误信息返回
func GetErrMsg(code int) string {
	return codeMsg[code]
}
